﻿using LitJson;
using System.Collections.Generic;
using UnityEngine;

namespace GameProtocol
{
    public sealed partial class FrameSyncData
    {
        public int PlayerCount { get { return playerDatas_.Count; } }
        public void SetPlayerFireState(uint playerID, bool fireState)
        {
            if (!playerDatas_.ContainsKey(playerID))
                playerDatas_.Add(playerID, new GameProtocol.FramePlayerSyncData());
            playerDatas_[playerID].Fire = fireState; 

        }
        public void SetPlayerMoveDir(uint playerID, Vector2Int dir)
        {
            if (!playerDatas_.ContainsKey(playerID))
                playerDatas_.Add(playerID, new GameProtocol.FramePlayerSyncData());
            playerDatas_[playerID].MoveDirX = dir.x;
            playerDatas_[playerID].MoveDirY = dir.y;
        }
        public void SetPlayerFocusPosition(uint playerID, Vector2Int position)
        {
            if (!playerDatas_.ContainsKey(playerID))
                playerDatas_.Add(playerID, new GameProtocol.FramePlayerSyncData());
            playerDatas_[playerID].FocusPosX = position.x;
            playerDatas_[playerID].FocusPosY = position.y;
        }
        public void SetPlayerAimPosition(uint playerID, Vector2Int position)
        {
            if (!playerDatas_.ContainsKey(playerID))
                playerDatas_.Add(playerID, new GameProtocol.FramePlayerSyncData());
            playerDatas_[playerID].AimPosX = position.x;
            playerDatas_[playerID].AimPosY = position.y;
        }
    }
}